package com.java.mytools.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangning
 * @create 2021-08-31 14:40
 */
@Api("测试Swagger")
@RestController
@RequestMapping("/swagger")
public class TestSwaggerController {

	@GetMapping("/hello")
	@ApiOperation("测试无参get方法")
	public String hello() {
		return "测试成功";
	}

	@GetMapping("/hello01")
	@ApiOperation("测试get当时传参")
	@ApiImplicitParam(name = "id", value = "参数id", required = true, dataType = "String", paramType = "path")
//	@ApiImplicitParams({@ApiImplicitParam()})
	public String hello01(String id) {
		return "测试成功" + id;
	}

	@GetMapping("/hello02/{id}")
	@ApiOperation("测试get方式restful方式传参")
	public String hello02(@PathVariable("id") String dd) {
		return "测试成功" + dd;
	}

	@PostMapping(value = "/hello03", produces="application/json")
	@ApiOperation(value = "name", notes = "ceshi")
	@ApiImplicitParam(name = "name", value = "姓名", required = true, dataType = "String", paramType = "form")
	public String hello03(String name) {
		return "测试成功" + name;
	}

	@PostMapping(value = "/hello04", produces="application/json;;charset=utf-8")
//	@PostMapping(value = "/hello04")
	@ApiOperation("测试post方式json提交")
//	@ApiImplicitParam(name = "name", value = "姓名", required = true, dataType = "String", paramType = "form")
//  @ApiImplicitParam不能用于json提交方式，可以用于表单提交
	@ApiParam(name = "name", value = "姓名")
	public String hello04(@RequestBody String name) {
		return "测试成功" + name;
	}

}
